import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import QtQuick3D.Effects 6.2

Rectangle {
    id: bigCard
    anchors.fill: parent
    color: cardColor
    radius: 20

    property var btnConfigs//传入的大卡片中按钮的数据

    Rectangle{//大卡片加上页边距的Rectangle
        id:bigCardContentRec
        width: parent.width - 15
        height: parent.height - 15
        anchors.centerIn: parent
        color:"transparent"

        GridLayout {
            anchors.fill: parent
            columns: 2
            rows: 3
            columnSpacing: 20
            rowSpacing: 20

            Repeater {
                model: btnConfigs.length
                delegate: Loader {
                    id:bigCardMiddleBtnLoader
                    sourceComponent: MiddleButton{}
                    Connections{
                        target: bigCardMiddleBtnLoader.item
                        function onMiddelBtnClickedSig(name){
                            if(name === "更多场景"){
                                moreScenePopup.open()
                            }else{
                                var jsonData = {
                                    "command":"scene",
                                    "data":{
                                        "name":name,
                                    }
                                }
                                tcpSocket.sendMsg(jsonData)
                            }
                        }
                    }

                    onLoaded: {
                        // 设置组件的属性
                        item.buttonImg = btnConfigs[index].img
                        item.buttonText = btnConfigs[index].text

                        Layout.fillHeight= true
                        Layout.fillWidth= true
                        Layout.column= index % 2
                        Layout.row= Math.floor(index / 2)
                    }
                }
            }
        }

    }

    Popup{//更多场景
        id:moreScenePopup
        width: bigCardContentRec.height
        height: bigCardContentRec.height
        x:bigCardContentRec.x
        y:bigCardContentRec.y
        modal: true
        contentItem: Rectangle {
            anchors.fill: parent
            color: "white"

            Text {
                id:hintPopupText
                text: "功能待开发"
                anchors.centerIn: parent
            }
            Button{
                anchors.bottom: hintPopup.bottom
                text:"关闭"
                onClicked: moreScenePopup.close()
            }
        }
        closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
        anchors.centerIn: parent

        background: Rectangle {
            color: "white" // 设置为透明
            border.color: textColor
            border.width: 1
            radius: 20
        }
    }
}



